package ModelLayer;
import java.util.ArrayList;


/**
 * Write a description of class LeaseContainer here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class LeaseContainer
{
    // instance variables - replace the example below with your own
    private ArrayList<Lease> leaseList;

    /**
     * Constructor for objects of class LeaseContainer
     */
    public LeaseContainer()
    {
        // initialise instance variables
        leaseList = new ArrayList<Lease>();
    }

    /**
     * An example of a method - replace this comment with your own
     * 
     * @param  y   a sample parameter for a method
     * @return     the sum of x and y 
     */
    
    public Lease getLease(long _id)
    {
        Lease l = new Lease();
        l = null;
        for (int i=0; i<leaseList.size(); i++)
        {
            if (leaseList.get(i).getId() == _id)
            { 
                l = leaseList.get(i);
                return l;
            }
            else
                l = null;
        }
        
        return l;
    }
    
    public void createLease(Lease _lease)
    {
        leaseList.add(_lease);
    }
    
    public void endLease(long _id, String _actReturnDate)
    {
        getLease(_id).setActReturnDate(_actReturnDate);
        getLease(_id).setStatusFalse();
    }
    
    public ArrayList<Lease> listAllLeases()
    {
        return leaseList;
    }
    
}
